package org.flashbrighton.as3bots.controllers
{
	import org.flashbrighton.as3bots.events.BotEvent;
	import org.flashbrighton.as3bots.models.CollidableType;

	public class JoesBotController implements IBotController
	{
		
		private var _enginePower:Number;
		private var _steeringPower:Number;		
		private var _state:String;
		
		
		public function JoesBotController()
		{
			_enginePower = 1;
			_steeringPower = 0;
			_state = "good";
		}

		
		public function run():void
		{
			if (_state == "bad")
			{
				_steeringPower = 1;
				_state = "good";
			}
			else if (_state == "good")
			{
				_steeringPower = 0;
			}
		}
		
		
		public function notify(event:BotEvent):void
		{
			if (event.collisionPoint > 0.5)
			{
				_state = "bad";
			}
			else
			{
				_state = "good";
			}
			
			if (event.targetType == CollidableType.WALL)
			{
				_state = "bad";
			}
		}
		
		
		public function getEnginePower():Number
		{
			return _enginePower;
		}
		
		
		public function getSteeringPower():Number
		{
			return _steeringPower;
		}
		
	}
}